<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>客户修改 </title>
    <base target="_self" />
    <link href="../Styles/css.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/ts_css.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="../Scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

    <script type="text/javascript">  
    /*加载项目下拉选*/  
    $(function () {  
        $.ajax({  
            type: "post", 
			dataType:"json",
            url: "/wanda/salechance/selectProjectAll.do",  
            success: function (data) {  
            	$('#projectName').empty();
				 $("#projectName").append("<option value=''>----选择楼栋----</option>");
			         $.each(data.tasks,function(index,item){
				         $("#projectName").append( "<option value='"+item.projectId+"'>"+item.projectName+"</option>");
	            });
            }, 
        });  
   
    
        $('#projectName').change(function(){
    		var projectId = $('#projectName').val();
    		//alert(projectId);
    		$.ajax({
    			url:"/wanda/unit/getBuild.do",
    			type:"post",
    			dataType:"json",
    			data:{"projectId":projectId},
    			success:function(data){
    				/* $('#buildName').empty();
    				 $("#buildName").append("<option value=''>----选择单元----</option>");
    				   $.each(data.tasks,function(index,item){
    					 $("#buildName").append( "<option value='"+item.buildId+"' >"+item.buildName+"</option>");
    		            }); */
    		      	$(data).each(function(){
  				 		$("#buildName").append("<option value="+this.buildId+">"+this.buildName+"</option>");
			   		});
    			}
    		});
    		
    		$('#buildName').change(function(){
        		var buildId = $('#buildName').val();
        		//alert(1);
        		//alert(buildId);
        		$.ajax({
        			url:"/wanda/unit/unitList.do",
        			type:"post",
        			dataType:"json",
        			data:{"buildId":buildId},
        			success:function(data){
        				/* $('#unitCode').empty();
        				 $("#unitCode").append("<option value=''>----选择单元----</option>");
        				   $.each(data.tasks,function(index,item){
        					  // alert(item.unitName);
        					 $("#unitCode" ).append( "+<option value='"+item.unitId+"'>"+item.unitName+"</option>");
        		        });*/
        		          $(data).each(function(){
							 $("#unitCode").append("<option value="+this.unitId+">"+this.unitCode+"</option>");
							    // floor = this.wdHtBuild.floorCount
						   });
			   
        			}
        		}); 
        	
        		$('#unitCode').change(function(){
            		var unitId = $('#unitCode').val();
            		//alert(unitId);
            		
            		$.ajax({
            			url:"/wanda/salechance/room.do",
            			type:"post",
            			dataType:"json",
            			data:{"unitId":unitId},
            			success:function(data){
            			
            				/* $('#roomCode').empty();
            				 $("#roomCode").append("<option value=''>----选择单元----</option>");
            				   $.each(data.tasks,function(index,item){
            					 $("#roomCode").append( "<option value='"+item.roomId+"'>"+item.roomName+"</option>");
            		            }); */
            		        $(data).each(function(){
							 $("#roomCode").append("<option value='"+this.roomId+"'>"+this.roomCode+"</option>");
							    // floor = this.wdHtBuild.floorCount
						   });
            			}
            		});
            	});	
    		}); 
    	}); 
    }); 
   
</script > 

</head>
<body>
    <form action="/wanda/salechance/WdSaleChanceAdd.do?projectId=${projectId}&roomId=${roomId}&buildId=${buildId}&unitId=${unitId}&" method="post">

    <div style="background: #EFF3FF; width: 22%; float: left; overflow-y: auto;">
        <div id="tree" class="tree" style="background: #EFF3FF;">
        </div>
    </div>
    <div style="width: 75%; float: left; border: 0px solid #82AFE8">
        <table width="100%">
            <tr>
                <td width="6%">
                   销售机会名称：
                </td>
                <td width="13%">
                <input name="saleChanceName" type="text" id="saleChanceName" style="width:95%;" />
                </td>
                <td width="7%">
                    客户意向：
                </td>
                <td width="13%">
                <input name="intentionDescription" type="text" id="intentionDescription" style="width:95%;" />
                </td>
            
                <td width="7%">
                    客户姓名：
                </td>
                <td width="13%">
                    <input name="customerName" type="text" id="customerName"  style="width:95%;" />
                </td>
            </tr>
            
            <tr>
                <td width="7%">
                    客户电话：
                </td>
                <td width="13%">
                 <input name="tel" type="text" id="tel" style="width:95%;" />
                </td>
                <td width="6%">
                    业务员名称：
                </td>
                <td width="13%">
                    <input name="userName" type="text" id="userName" style="width:95%;" />
                </td>
            
                <td width="7%">
                    意向项目：
                </td>
                <td width="13%">
                   <!--  <input name="projectName" type="text" id="projectName"  style="width:95%;" />
                     -->
                     <select class="select" id="projectName" name="projectName" >  
                        <option value="">请选择</option>  
                        <c:forEach  items="${ddddd }" var="ctojepr">
                        <option value="${ctojepr.projectId }">${ctojepr.projectName }</option>
                        </c:forEach>
                    </select> 
                </td>
            </tr>
            
            <tr align="center">
              <tr>
                <td width="7%">
                    意向楼栋：
                </td>
                <td width="13%">
                 <!-- <input name="buildName" type="text" id="buildName" style="width:95%;" />
                --> 
                 <select class="select" id="buildName" name="buildName">  
                        <option value="">请选择</option>  
                 </select> 
                </td>
                <td width="6%">
                    意向单元：
                </td>
                <td width="13%">
                   <!--  <input name="unitCode" type="text" id="unitCode" style="width:95%;" />
                    --><select class="select" id="unitCode" name="unitCode" >  
                        <option value="">请选择</option>  
                 </select> 
                </td>
            
                <td width="7%">
                    意向房间：
                </td>
                <td width="13%">
                   <!--  <input name="roomCode" type="text" id="roomCode"  style="width:95%;" />
                -->
                   <select class="select" id="roomCode" name="roomCode">  
                        <option value="">请选择</option>
                 </select> 
                </td>
            </tr> 
            <!-- <tr align="center">
               <td width="5%" colspan="6">
                    <input type="submit" style="float: right" value="添加" />
               </td>
            </tr> -->
            
          <tr align="center">
               <td width="5%" colspan="6">
                   <a  href="javascript:void(0)" onclick="add('${slist.saleChanceId}','${userId}')">提交</a>
               </td>
            </tr> 
        </table>
        
        <script>
			function add(saleChanceId, userId) {
				//alert("unitId");
				var saleChanceName = document.getElementById("saleChanceName").value;
				var intentionDescription = document.getElementById("intentionDescription").value;
				var customerName = document.getElementById("customerName").value;
				var tel= document.getElementById("tel").value;
				var userName = document.getElementById("userName").value;
				var projectId = document.getElementById("projectName").value;
				var buildId = document.getElementById("buildName").value;
				var unitId = document.getElementById("unitCode").value;
				var roomId = document.getElementById("roomCode").value;
				//alert(customerName);
				
				location.href = "/wanda/salechance/WdSaleChanceAdd.do?saleChanceId="
							+ saleChanceId + "&userId=" + userId + "&projectId=" + projectId 
							+ "&buildId=" + buildId + "&unitId=" + unitId + "&roomId=" + roomId
							+ "&saleChanceName=" + saleChanceName+ "&intentionDescription=" + intentionDescription+ "&customerName=" + customerName
							+ "&tel=" + tel+ "&userName=" + userName;
				
			}
		</script>
</form>
</body>
</html>
